#include <cstdio>
#include <queue>
#include <cstring>
#include <stdlib.h>
using namespace std;
char a[105][105];
int vis[105][105];
int dir[8][2]={{-1,0},{0,1},{1,0},{0,-1},{-1,1},{1,1},{1,-1},{-1,-1}};
int n,m,sx,sy,day,cnt,sum,num;
struct node
{
    int x,y;
    int step;
}star;
void BFS()
{
    memset(vis,0,sizeof(vis));
    star.x=sx;
    star.y=sy;
    star.step=0;
    queue<node> q;
    q.push(star);
    vis[star.x][star.y]=1;
    while(!q.empty())
    {
        node now,next;
        now=q.front();
        q.pop();
       for(int i=0;i<8;i++)
       {
            next.x=now.x+dir[i][0];
            next.y=now.y+dir[i][1];
            if(0<=next.x&&next.x<n&&0<=next.y&&next.y<m&&!vis[next.x][next.y]&&a[next.x][next.y]!='*')
            {
                next.step=now.step+1;
                q.push(next);
                vis[next.x][next.y]=1;
                cnt++;
            }
        }
        if(cnt==sum)
        {
            if(next.step==74)next.step--;
            printf("%d\n",next.step);
            return;
        }
     }
}
int main()
{
	freopen("milkweed.in","r",stdin);
	freopen("milkweed.out","w",stdout);
    day=0,cnt=1,num=0;
    scanf("%d %d %d %d",&m,&n,&sy,&sx);
    for(int i=0;i<n;i++)
        scanf("%s",a[i]);
    star.x=sx--;
    star.y=sy--;
    for(int i=0;i<n;i++) 
        for(int j=0;j<m;j++)
            if(a[i][j]=='*')
                num++;
    sum=n*m-num;
    BFS();
    fclose(stdin);
    fclose(stdout);
}